#ifndef _thread_h_
#define _thread_h_

// thread.h
//
// Threading functionality, or null for platforms that
// do not support (or do not need) this functionality

// Decide which implementation to use
// Defining SIMPLE_NOTHREADS will use the default implementation in
// applications where threading isn't an issue.

#if !defined(SIMPLE_NOTHREADS) && defined(WIN32)
#include <win32/thread.h>
#elif !defined(SIMPLE_NOTHREADS) && defined(HasPTHREADS)
#include <unix/thread.h>
#else

namespace simple{

    //
    // Thread
    //
    // Thread is a simple wrapper around a threading object to
    // start and execute a thread. This default version does nothing and
    // is suitable for platforms that do not support threading, or
    // applications that do not require it.

    class Thread
    {
    public:
        Thread  () {}
        ~Thread () {}

        int threadid () const { return 0;}
        // Return thread id

        bool start () { return false;}
        // Start the thread running. return false on error

        bool stop  () { return false;}
        // Stop the thread. Ungraceful and may result in locking/resource problems.

        bool wait (unsigned int seconds = 0) { return false;}
        // Wait for thread to complete. Return true if thread is finished

        void sleep (unsigned int msec) {}
        // Sleep for the specified amount of time.

    protected:
        virtual void thread () {}        // Thread function, never returns
    };
}
#endif


#endif // _thread_h_
